package by.dvrudenko.avtobaza.datamodel;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import by.dvrudenko.avtobaza.datamodel.enums.OrderStatus;

@Entity
public class UserOrder implements Serializable{
	
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	@NotNull
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = User.class)
	private User user;	

	@Column
	private Timestamp orderDate;
	
	@Column 
	@Size(max = 1000)
	private String cargoDescription;
	
	@NotNull	
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = City.class)
	private City cargoBeginningCity;
	
	@Column
	@NotNull
	private String cargoBeginningCoordinate;
	
	@NotNull	
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = City.class)
	private City cargoFinalCity;
	
	@Column
	@NotNull
	private String cargoFinalCoordinate;

	@Column
	private String anyDescription;
	
	@Column
	@Min(value = 0)
	@NotNull
	private Integer cargoWeight;
	
	@Column
	@Min(value = 0)
	@NotNull
	private Integer cargoVolume;
	
	@Column
	@NotNull
	@Enumerated (EnumType.STRING)
	private OrderStatus orderStatus;

	public Timestamp getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Timestamp orderDate) {
		this.orderDate = orderDate;
	}

	public Integer getCargoWeight() {
		return cargoWeight;
	}

	public void setCargoWeight(Integer cargoWeight) {
		this.cargoWeight = cargoWeight;
	}

	public Integer getCargoVolume() {
		return cargoVolume;
	}

	public void setCargoVolume(Integer cargoVolume) {
		this.cargoVolume = cargoVolume;
	}

	public OrderStatus getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(OrderStatus orderStatus) {
		this.orderStatus = orderStatus;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getCargoDescription() {
		return cargoDescription;
	}

	public void setCargoDescription(String cargoDescription) {
		this.cargoDescription = cargoDescription;
	}

	public String getAnyDescription() {
		return anyDescription;
	}

	public void setAnyDescription(String anyDescription) {
		this.anyDescription = anyDescription;
	}
	
	public City getCargoBeginningCity() {
		return cargoBeginningCity;
	}

	public void setCargoBeginningCity(City cargoBeginningCity) {
		this.cargoBeginningCity = cargoBeginningCity;
	}

	public String getCargoBeginningCoordinate() {
		return cargoBeginningCoordinate;
	}

	public void setCargoBeginningCoordinate(String cargoBeginningCoordinate) {
		this.cargoBeginningCoordinate = cargoBeginningCoordinate;
	}

	public City getCargoFinalCity() {
		return cargoFinalCity;
	}

	public void setCargoFinalCity(City cargoFinalCity) {
		this.cargoFinalCity = cargoFinalCity;
	}

	public String getCargoFinalCoordinate() {
		return cargoFinalCoordinate;
	}

	public void setCargoFinalCoordinate(String cargoFinalCoordinate) {
		this.cargoFinalCoordinate = cargoFinalCoordinate;
	}
	
	

}
